<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>基础资料-负责人</title>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',height:'auto'" class="tool-bar-style">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-add',onClick:btn_page_basic_leader_add">新增</a>
        <a class="easyui-linkbutton" data-options="iconCls:'icon-edit',onClick:btn_page_basic_leader_update">修改</a>
        <a class="easyui-linkbutton" data-options="iconCls:'icon-redo',onClick:btn_page_basic_leader_export">导出</a>
        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel',onClick:btn_page_basic_leader_delete">停用查询</a>
        <a class="easyui-linkbutton" data-options="iconCls:'icon-reload',onClick:btn_page_basic_leader_reload">刷新</a>
    </div>
    <div data-options="region:'center'">
        <table id="page_basic_leader_grid"></table>
    </div>
</div>
<script type="text/javascript">
    $('#page_basic_leader_grid').datagrid({
        url: 'principal/listQuery',
        method: 'GET',
        queryParams: {principalStatus: 1},
        striped: true,
        fit: true,
        sortable: true,
        rownumbers: true,
        remoteSort: false,
        idField: 'id',
        showFooter: true,
        singleSelect: true,
        columns: [[
            {field: 'id', title: '主键', hidden: true, align: 'center', halign: 'center', width: 80,},
            {
                field: 'personName',
                title: '负责人',
                align: 'center',
                halign: 'center',
                width: 80,
                input: {type: 'easyui-textbox', dataoptions: `required:true`}
            },
            {
                field: 'remarks',
                title: '备注',
                align: 'center',
                halign: 'center',
                width: 120,
                input: {type: 'easyui-textbox', dataoptions: `required:false`}
            },
            // {field: 'createTime', title: '创建时间', align: 'center', halign: 'center', width: 135},
            {
                field: 'userStatus',
                title: '停用',
                hidden: true,
                align: 'center',
                halign: 'center',
                width: 80,
                input: {
                    type: 'easyui-combobox',
                    dataoptions: `height:'auto',required:true,data:[{id: 0, text: '停用'}, {id: 1, text: '正常'}],textField:'text',valueField:'id',editable:false,value:1`
                }
            },
        ]],
        onLoadSuccess: function (data) {
            $(this).datagrid('enableFilter');
        },
        onBeforeLoad: function (param) {
            $(this).datagrid('destroyFilter');
            return true;
        },
        onDblClickRow: function (index, row) {
            btn_page_basic_leader_update();
        }
    })

    /** 新增 */
    function btn_page_basic_leader_add() {
        $('#page_basic_leader_grid').datagrid("initAddDialog", {
            height: 'auto',
            url: "principal/insertSelective",
            method: 'POST',
            // extra: {pId: $("#tree").tree("getSelected").id}
        });
    }

    /** 修改 */
    function btn_page_basic_leader_update() {
        let selected = $('#page_basic_leader_grid').datagrid('getSelected');
        if (selected == undefined) {
            $.messager.alert('提示', '未选中', 'warning');
            return;
        }
        $("#page_basic_leader_grid").datagrid("initEditableDialog", {
            height: 'auto',
            url: "principal/updateSelective",
            method: 'post',
            extra: {id: selected.id}
        });
    }

    /** 删除 */
    function btn_page_basic_leader_delete() {
        $('#page_basic_leader_grid').datagrid('reload', {principalStatus: 0});
    }

    /** 新增 */
    function btn_page_basic_leader_export() {
        $('#page_basic_leader_grid').datagrid('toExcel', '责任人.xls');
    }

    /** 刷新 */
    function btn_page_basic_leader_reload() {
        $('#page_basic_leader_grid').datagrid('reload', {principalStatus: 1});
    }
</script>
</body>
</html>